<!--
 * @Author: xfworld
 * @Date: 2020-03-13 15:56:17
 * @LastEditors: xfworld
 * @LastEditTime: 2020-06-10 15:20:40
 * @Description: 
 -->
<template>
  <div id="mine">
    <van-nav-bar title="我的" :fixed="true" :border="false" />
    <van-cell-group style="margin-top:1rem">
      <van-cell style="background-color: #3bba63;color:#FFF;" label-class="labelClass" is-link center>
        <template slot="title">
          <!-- 已登录状态 -->
          <div class="personMsg" v-if="userInfo.token" @click="goToPage('userCenter')">
            <img class="iconImage" :src="user_image.login_icon" alt="" />
            <div class="sex" v-if="userInfo.sex">
              <img :src="userInfo.sex == '1' ? user_image.female : user_image.male" alt="" />
            </div>
            <div class="personInfo" v-if="userInfo.token">
              <span>{{ userInfo.user_name }}</span>
              <span>联系方式：{{ userInfo.phoneNumber }}</span>
            </div>
          </div>
          <!-- 未登录状态 -->
          <div class="personMsg" v-if="!userInfo.token">
            <img class="iconImage" :src="user_image.noLogin_icon" alt="" />
            <div class="personInfo" v-if="!userInfo.token">
              <div @click="goToPage('login')">
                登录
              </div>
            </div>
          </div>
        </template>
      </van-cell>
    </van-cell-group>
  </div>
</template>

<script>
// @ is an alias to /src

export default {
  name: "home",
  components: {},

  created() {},
  mounted() {},
  data() {
    return {
      user_image: {
        login_icon: require("../../../assets/image/cat.jpg"),
        noLogin_icon: require("../../../assets/image/grey.jpg"),
        female: require("../../../assets/image/female.png"),
        male: require("../../../assets/image/male.png")
      },
      userInfo: {
        user_name: "王力",
        phoneNumber: 12121212121,
        token: true
      }
    };
  },
  methods: {}
};
</script>

<style lang="less">
#mine {
  width: 100%;
  background-color: #f5f5f5;
  margin-bottom: 3rem;
  .version {
    margin: 0 auto;
    text-align: center;
    font-size: 0.6rem;
    background-color: #ffffff;
    height: 2rem;
    color: grey;
    line-height: 2rem;
  }
  .van-nav-bar {
    background-color: #3bba63;
    font-size: 0.6rem;
  }
  .van-nav-bar__title {
    color: white;
  }
  .personMsg {
    display: flex;
    align-items: center;
    .sex {
      position: absolute;
      top: 3.5rem;
      left: 3.8rem;
      width: 0.1rem;
      height: 0.1rem;
      img {
        width: 1rem;
        height: 1rem;
      }
    }
    img {
      width: 4rem;
      height: 4rem;
      border-radius: 50%;
    }
    .personInfo {
      display: flex;
      flex-direction: column;
      margin-left: 0.8rem;
    }
  }
  .van-cell__left-icon {
    color: #45c763;
    font-size: 1.2rem;
  }
  /*转场动画*/
  .router-slider-enter-active,
  .router-slider-leave-active {
    transition: all 0.3s;
  }
  .router-slider-enter,
  .router-slider-leave-active {
    transform: translate3d(2rem, 0, 0);
    opacity: 0;
  }
}
</style>
